package controller

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"mysajfih/model"
	"mysajfih/schemas"
)

func News(userGrp *gin.RouterGroup) {
	userGrp.Use().POST("/addnews", addNews)
	userGrp.Use().GET("/asd", getNews)

}

func addNews(c *gin.Context) {

	news := &schemas.News{}
	//绑定参数
	_ = c.Bind(news)

	news1 := &model.User{
		Name:          news.Name,
		NameTelephone: news.NameTelephone,
		Password:      news.Password,
	}
	db := model.GetDb()
	res := db.Create(news1)
	c.JSON(200, gin.H{
		"code": "10010",
		"tes":  res,
	})

}

func getNews(c *gin.Context) {
	fmt.Println("添加新闻")

}
